Skip to content

chore: don't accept multiple arguments in :LspStop/LspRestart #3896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

toupeira
Copy link
Contributor

@toupeira toupeira commented Jun 9, 2025

Description

We don't want to support multiple arguments in the upcoming :Lsp multi-command, so remove this now from :LspStop and :LspRestart.

Context

@justinmk
Copy link
Member

justinmk commented Jun 10, 2025

I would prefer that neither of them supported multiple args. What is the use-case? These commands should not be used in scripts. Interactive usage is typically not going to specify multiple names.

Scripts should use vim.lsp, not these commands. Commands are for interactive use.

@toupeira
Copy link
Contributor Author

@justinmk that sounds good to me too, I just added this for consistency with the LspStop and LspRestart commands.

I personally don't have a use case, but I'm also not sure if we should change the behaviour of LspStop / LspRestart now since I guess that would technically be a breaking change. Maybe I should leave this alone, and then any new behaviour can be implemented in the upstreamed :Lsp multi-command?

(if you agree feel free to close this PR 😀)

@justinmk
Copy link
Member

but I'm also not sure if we should change the behaviour of LspStop / LspRestart now since I guess that would technically be a breaking change.

We should make that change. The goal is to get the code in shape and then upstream it to core Nvim.

@toupeira toupeira force-pushed the feat/lspstart-with-multiple-arguments branch from dbf39bd to b0b2276 Compare June 13, 2025 19:16
We don't want to support multiple arguments in the upcoming `:Lsp`
multi-command, so remove this now from `:LspStop` and `:LspRestart`.
@toupeira toupeira force-pushed the feat/lspstart-with-multiple-arguments branch from b0b2276 to efc7246 Compare June 13, 2025 19:18
@toupeira toupeira changed the title feat: support multiple config names in :LspStart chore: don't accept multiple arguments in :LspStop/LspRestart Jun 13, 2025
@toupeira
Copy link
Contributor Author

@justinmk ok I changed this now! I hope nobody's relying on this, but I guess all these commands will get deprecated soon anyway 😀

I noticed that with nargs = '?' and passing multiple arguments, info.fargs then just contains a single string (e.g. foo bar). So I didn't add any special error handling and users will just see the notification Invalid server name 'foo bar', which I guess is good enough?

Let me know if there's an easy way to avoid this, i.e still getting the split arguments in fargs.

@@ -153,8 +153,8 @@ Most of the time, the reason for failure is present in the logs.

* `:LspInfo` (alias to `:checkhealth vim.lsp`) shows the status of active and configured language servers.
* `:LspStart <config_name>` Start the requested server name. Will only successfully start if the command detects a root directory matching the current config.
* `:LspStop [<client_id_or_name> ...]` Stops the given server(s). Defaults to stopping all servers active on the current buffer. To force stop add `++force`
* `:LspRestart [<client_id_or_name> ...]` Restarts the given client(s), and attempts to reattach to all previously attached buffers. Defaults to restarting all active servers.
* `:LspStop [<client_id_or_name>]` Stops the given server. Defaults to stopping all servers active on the current buffer. To force stop add `++force`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

off-topic/future: why didn't we use ! instead of ++force to "force" ...?

desc = 'Disable and stop the given client(s)',
nargs = '*',
desc = 'Disable and stop the given client',
nargs = '?',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I thought it would simplify the implementation too :)

well, let's try it for now and see how it goes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we still need to handle multiple servers in the default case with no arguments 😀

Thanks for the merge!

@justinmk justinmk merged commit 7ad4a11 into neovim:master Jun 13, 2025
6 checks passed
@toupeira toupeira deleted the feat/lspstart-with-multiple-arguments branch June 13, 2025 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants